const promise1 = new Promise((res, rej) => {
  setTimeout(res, 100, 'foo');
});
const promise2 = new Promise((res, rej) => {
  setTimeout(res, 200, 'bar');
});
Promise.race([promise1, promise2]).then(values => {
  console.log(values); // 'foo'
});
const promise3 = Promise.resolve(3);
const promise4 = 2;
const promise5 = new Promise((res, rej) => {
  setTimeout(res, 100, 4);
})
Promise.all([promise3, promise4, promise5]).then(values => {
  console.log(values); // [3, 2, 4]
});